<?php

namespace paymch\modules\test\controllers;

use Yii;
use yii\web\Controller;

/**
 * TradeCreateController for the `test` module
 */
class TradeCreateController extends Controller {

    /**
     * Renders the index view for the module
     * @return string
     */
    public function actionIndex() {
        $host = Yii::$app->request->hostInfo;
        $client = new \common\components\paymch\MchClient();
        $client->appId = '201710139118';
        $client->rsaPrivateKeyFilePath = Yii::getAlias('@paymch') . '/data/keys/emchpay/rsa_private_key.pem';
        $client->gatewayUrl = $host . '/trade/create';
        $client->signType = 'RSA2';
        $client->postCharset = 'utf-8';
        $client->apiVersion = '1.0';
        $params = [
            'bizno' => '2013112011001004330000121536',
            'buyer_id' => '1',
            'paymode' => 'alipay',
            'total_amount' => '0.1',
            'point_amount' => '1',
            'subject' => '商品A标题',
            'body' => '商品A内容',
            'expire_time' => '20171130191200',
            'return_url' => 'http://blog.csdn.net/ljfrocky/article/details/46373691',
        ];
        $data = $client->render($params);
        return \yii\helpers\VarDumper::export($data);
    }

}
